package cn.ldf.keepaccounts.dao;

import cn.ldf.keepaccounts.entity.pojo.Rooms;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 房间表(Rooms)表数据库访问层
 *
 * @author 清峰
 * @since 2025-02-17 10:15:14
 */
@Mapper
public interface RoomsDao extends BaseMapper<Rooms> {
    /**
     * 根据openId和状态且用户未结算 查询房间信息
     * @param openId 用户openId
     * @param status 房间状态
     * @return 结果集
     */
    @Select("SELECT t1.* FROM rooms t1 JOIN members t2 ON t2.room_id = t1.room_id WHERE t1.`status` = #{status} AND t2.open_id = #{openId}  AND t2.settled = 0 GROUP BY t1.id")
    Rooms getRoomByOpenIdAndStatus(@Param("openId") String openId,@Param("status") String status);
}

